    #include <iostream>
    int main()
    {
        int sum = 0, value;
        // read till end-of-file, calculating a running total of all values read
        //注意，如果cin读取的字符不是整数，则while的循环条件为false，此时会跳出循环。
        //因此，输入 1 3 5 .会得到总和为9的结果。
        //或者输入 1 3 5回车 CTRL+Z(End of Line快捷键)
        while (std::cin >> value)
            sum += value; // equivalent to sum = sum + value
        std::cout << "Sum is: " << sum << std::endl;
        return 0;
     }

/*
* Entering an End-of-file from the Keyboard
* Operating systems use different values for end-of-file.
* On Windows systems we enter an end-of-file by typing a control-z simultaneously type the "ctrl" key and a "z."
* On UNIX systems, including Mac OS-X machines, it is usually control-d.
*/
